#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <stack>
#include <string>
using namespace std;
string str[21];
char numbers[21][100] = {
    "[+[]]",
    "[+!![]]",
    "[!![]+!![]]",
    "[!![]+!![]+!![]]",
    "[!![]+!![]+!![]+!![]]",
    "[!![]+!![]+!![]+!![]+!![]]",
    "[!![]+!![]+!![]]*[!![]+!![]]",
    "[+!![]+[+[]]-!![]-!![]-!![]]",
    "[+!![]+[+[]]-!![]-!![]]",
    "[+!![]+[+[]]-!![]]",
    "[+!![]+[+[]]]",
    "[+!![]+[+!![]]]",
    "[-[-!![]+[+!![]]-!![]]]",
    "[-[-!![]+[+!![]]-!![]-!![]]]",
    "[!![]+!![]+!![]-[-!![]+[+!![]]]]",
    "[!![]+!![]+!![]+!![]-[-!![]+[+!![]]]]",
    "[+!![]+[+[]]-!![]-!![]]*[!![]+!![]]",
    "[!![]+!![]+[+[]]-!![]-!![]-!![]]",
    "[!![]+!![]+[+[]]-!![]-!![]]",
    "[!![]+!![]+[+[]]-!![]]",
    "[!![]+!![]+[+[]]]"
};
void init()
{
    string tmp, first, second;
    str[0] = "+!![]";
    str[1] = "+[+!![]+[+[]]]";
    for (int i = 2; i <= 20; i++)
    {
        // +["1"+"0"+...+"0"]
        str[i] = "+[+!![]";
        for (int j = 0; j < i; j++) str[i] += "+[+[]]";
        str[i] += "]";
        // [10^i] * [10^j]
        for (int j = 1; j < i; j++)
        {
            // form of "+[string]"
            if (str[j][0] == '+') first = str[j].substr(1, str[j].length() - 1);
            else first = str[j];
            if (str[i - j][0] == '+') second = str[i - j].substr(1, str[i - j].length() - 1);
            else second = str[i - j];
            tmp = first + "*" + second;
            if (tmp.length() < str[i].length()) str[i] = tmp;
            else if (tmp.length() == str[i].length() && tmp < str[i]) str[i] = tmp;
        }
        // +["1"+"e"+"i"]
        first = numbers[i];
        tmp = "+[+!![]+[!![]+[]][+![]][!![]+!![]+!![]]+" + first + "]";
        if (tmp.length() < str[i].length()) str[i] = tmp;
        else if (tmp.length() == str[i].length() && tmp < str[i]) str[i] = tmp;
    }
}
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t, n;
    init();
    scanf("%d", &t);
    while (t--)
    {
        scanf("%d", &n);
        puts(str[n].c_str());
    }
    return 0;
}
